<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'north'" class="center" style="">
        <div class="webmap">
            <p class="webmaptip">当前位置:</p>
            <a href="javascript:;" class="easyui-link" data-options="plain:true">财务管理</a>
            <p class="webmaptip">></p>
            <a href="javascript:;" class="easyui-link" data-options="plain:true">用户收支</a>
        </div>
        <div class="querybycon">
            <form id="query">
                <div class="queryinfo">
                    <div>用户名<input type="text" name="user.telephone"></div>
                    <div>交易类型 <input class="easyui-combobox" name="trdType"
                                     data-options="url:'/dictionary/userTradeType?all=true'"></div>
                    <div style="width: 470px;">
                        交易时间 <input name="beginTime" class="easyui-datetimebox"> - <input name="endTime"
                                                                                          class="easyui-datetimebox">
                    </div>
                    <div class="query">
                        <a id="querybtn" href="javascript:;" class="easyui-linkbutton"
                           data-options="iconCls:'fa fa-search'"></a>
                    </div>
                </div>
            </form>
        </div>
        <div class="querybtn">
            <a id="exportbtn" href="javascript:;" class="easyui-linkbutton  "
               data-options="iconCls:'fa fa-search'">导出</a>
        </div>
        <div class="separator"></div>
    </div>
    <div data-options="region:'center'" class="center">
        <table id="list"></table>
    </div>
</div>

<script type="text/javascript">

    var delUrl = '';
    var save = '';
    var listUrl = "/userTradeDetail/list";
    var exportUrl = "/userTradeDetail/export";
    var edit = "";

    var columns = [[{
        field: 'id',
        checkbox: true
    }, {
        field: 'trdNo',
        title: '交易单号',
    }, {
        field: 'user',
        title: '用户名',
        formatter: function (value) {
            return value['telephone'];
        }
    }, {
        field: 'trdType',
        title: '交易类型',
        formatter: function (value, row, index) {
            return dic["userTradeType"][value.toString()];
        }

    }, {
        field: 'trdDirec',
        title: '交易方向',
        formatter: function (value, row, index) {
            switch (value) {
                case 1 :
                    return '收入';
                case 2 :
                    return '支出';
                default :
                    return '未知类型';
            }
        }
    }, {
        field: 'trdAmt',
        title: '交易金额(元)', formatter: function (value) {
            return formatNumber(value, 2);
        }
    }, {
        field: 'fee',
        title: '手续费/平台服务费(元)', formatter: function (value) {
            return formatNumber(value, 2);
        }
    }, {
        field: 'arriAmt',
        title: '到账金额(元)', formatter: function (value) {
            return formatNumber(value, 2);
        }
    }, {
        field: 'balance',
        title: '可用金额(元)', formatter: function (value) {
            return formatNumber(value, 2);
        }
    }, {
        field: 'remark',
        title: '详情',
    }, {
        field: 'trdTime',
        title: '交易时间',
    }]];
    list.init({url: listUrl, columns: columns});
    $("#exportbtn").click(function () {
        var obj = $("#query").serializeObject();
        window.open(exportUrl + "?" + $(obj).formatJson2Url());
    });
    function formatNumber(value, fixed) {
        var number = Number(value);
        if (isNaN(number)) {
            return '';
        } else {
            return number.toFixed(2);
        }
    }
</script>
